<?php header("Content-Type: text/html; charset=ISO-8859-1",true);
include "../conexao.php";

session_start();

if (!isset($_SESSION["txt_login"]) and !isset($_SESSION["txt_senha"])) 

{

  	print "<script type = 'text/javascript'> location.href = 'index.php'</script>";

}


$acao 			= $_GET["acao"];
$id 			= $_GET["id"];

if ($acao != "") 
{
	$sql = "SELECT c.*, s.* FROM categoria c, subcategoria s WHERE c.id_categoria = s.id_categoria  and id_subcategoria= '$id'";
	
	$resultado = mysql_query ($sql);
	$linha = mysql_fetch_array($resultado);
	
	
	$subcategoria = $linha['subcategoria'];
	$id_categoria	= $linha['id_categoria'];

}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
	font-size: 20px;
}
-->
</style>
<link href="estilo.css" rel="stylesheet" type="text/css" />
</head>

<body><div id="conteudo">
<table width="99%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><?php if ($acao =="Excluir") {?><font color="#FF0000">Obs: Cuidado, ao excluir uma subcategoria todas as noticas desta subcategoria tamb&eacute;m ser&atilde;o exclu&iacute;das</font><?php }?>
      <div align="right"><font color="red"><a href="javascript:abre('lst_subcategoria_noticias.php','GET')">Voltar</a></font></div></td>
  </tr>
  <tr>
    <td><form id="form1" name="form1" method="post" action="op_subcategoria_noticias.php">
      <table width="51%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td class="meio"><table width="314" border="0" align="center" cellpadding="3" cellspacing="0">
            <tr>
              <td colspan="2" align="center" bgcolor="#CCCCCC" class="estilo_L"><span class="style1">Subcategorias</span></td>
            </tr>
            <tr>
              <td width="76" bgcolor="#F5F5F5" class="estilo_L"><strong>Categoria</strong></td>
              <td width="224" bgcolor="#F5F5F5" class="estilo_L"><select name = "id_categoria">
                  <option> </option>
                  <?php 
		  		$sql_cat = "select * from categoria order by categoria";
				$result = mysql_query($sql_cat);
				
				while ($registro = mysql_fetch_array($result))
				{
					$valor = $registro["id_categoria"];
					
					if ($id_categoria == $valor)
					   $selecionado = "selected";
					else
						$selecionado = "";
					
					//print "<option value = \"$valor\" $selecionado > $registro['categoria'] </option>";
					echo "<option 'id_categoria' value = \"$valor\" $selecionado > $registro[categoria] </option>";
				}
		  
		  ?>
              </select></td>
            </tr>
            <tr>
              <td bgcolor="#F5F5F5" class="estilo_L"><strong>Subcategoria</strong></td>
              <td width="224" bgcolor="#F5F5F5" class="estilo_L"><input name="txt_subcategoria" type="text" id="txt_subcategoria" size="35" value= "<?php echo $subcategoria; ?>" /></td>
            </tr>
            <tr>
              <td colspan="2" bgcolor="#F5F5F5" class="estilo_L"><label>
                  <div align="center">
                    <input type="hidden" name="id" value= " <?php echo $id; ?>" />
                    <input type="hidden" name="acao" value = "<?php if ($acao !="") {echo $acao;} else { echo "Inserir";} ?>" />
                    <input type="submit" name="Submit" value="<?php if ($acao !="") {echo $acao;} else { echo "Inserir";} ?>" />
                  </div>
                </label></td>
            </tr>
          </table></td>
        </tr>
      </table>
    </form></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table></div>
</body>
</html>
